<html>
<head>
<title>Tutorial 1 Stage 4 - Working with groups</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td width="100%">
			<table width="100%" height="78" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="topnav">
			<tr>
				<!-- Header Side -->
				<td width="17">
					<img height="78" src="media/reportico100.png"/>
				</td>
				<td align="right"></td>
				<td align="center">
					<table width="100%" height="60" border="0" align="left" cellpadding="0" cellspacing="0">
						<tr>
							<td valign="top" align="left">
							<img src="media/repbanner.png"/></td>
							</td>
						</tr>
						<tr>
							<td align="center" valign="bottom" class="topmenucell">
								<nobr>
								&nbsp;
								</nobr>
							</td>
						</tr>
					</table>
				</td>
				<td width="103" class="toplogincell">
					&nbsp;
				</td>
			</tr>
			</table>
</td>
  </tr>
  <!--tr>
    <td class="header_top">reportico</td>
  </tr-->
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
  		  [ <a href="../classtrees_reportico.html" class="menu">class tree: reportico</a> ]
		  [ <a href="../elementindex_reportico.html" class="menu">index: reportico</a> ]
		  [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
      <b>Packages:</b><br />
              <a href="../li_reportico.html">reportico</a><br />
            <br /><br />
		<b>Tutorials/Manuals:</b><br />
					<strong>Package-level:</strong>
							<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.pkg.html">Reportico Tutorial And User Manual</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.manual.pkg.html">Reportico User Manual</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.quickstart.pkg.html">Reportico Installation</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.gettingstarted.pkg.html">Getting Started</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.structure.pkg.html">Reportico Installation Structure</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.using.pkg.html">Configuring Reportico - System Parameters</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.embedding.pkg.html">Embedding Reportico</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.security.pkg.html">Reportico Security</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.language.pkg.html">Language Support</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.projects.pkg.html">Projects</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.importlink.pkg.html">Importing and linking from reports</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.menus.pkg.html">Report Menus</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.prepare.pkg.html">Report Preparation and Execution</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.design.pkg.html">Report Design Mode</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.format.pkg.html">The Design Format Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.customcode.pkg.html">Custom Source Code</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.qrydet.pkg.html">The Query Details Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.assign.pkg.html">The Assignments Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.criteria.pkg.html">The Criteria Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.output.pkg.html">The Output Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.webservices.pkg.html">Turning Reports into Web Services (currently unavailable)</a>
</ul>
</li></ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.faq.pkg.html">Reportico FAQ</a>
</ul>
</li></ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.howto.pkg.html">Reportico Tutorial</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1.pkg.html">Tutorial No.1 - The Film Listing Report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_1.pkg.html">Tutorial 1 Stage 1 - Creating a basic report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_2.pkg.html">Tutorial 1 Stage 2 - Creating User Entry Criteria</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_3.pkg.html">Tutorial 1 Stage 3 - Working with expressions using assignments</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_4.pkg.html">Tutorial 1 Stage 4 - Working with groups</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_5.pkg.html">Tutorial 1 Stage 5 - Including database graphics into the report and generating drilldowns</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial2_1.pkg.html">Tutorial 2 - Creating the loan history report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial3_1.pkg.html">Tutorial 3 - The Monthly Returns Report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial4_1.pkg.html">Tutorial 4 - The Late Returns Summary report</a>
</ul>
</li></ul>
</li></ul>

							<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.appendix1.pkg.html">Appendix 1 - Reportico Project Configuration parameters</a>
</ul>

							<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.appendix2.pkg.html">Appendix 2 - Reportico URL request parameters</a>
</ul>

									                        <b>Files:</b><br />
      	  <div class="package">
			<a href="../reportico/_reportico.php.html">		reportico.php
		</a><br>
	  </div><br />
      
                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" align="left" valign="bottom"><a href=
"../reportico/tutorial_reportico.tutorial1_3.pkg.html">Prev</a></td>
<td width="80%" align="center" valign="bottom"></td>
<td width="10%" align="right" valign="bottom"><a href=
"../reportico/tutorial_reportico.tutorial1_5.pkg.html">Next</a></td>
</tr>
</table>
<span><a name="using."></a><h2 class="title">Tutorial 1 Stage 4 - Working with groups</h2>In this stage you will learn how to :-
    <p><ol><li><p>Create a group with headers and trailers</p></li>
	<li><p>Create group sums, averages, minums, maximums</p></li></ol></p>
   <a name="tut1_4_run"></a><h3 class="title">Beginning the Tutorial 1 Stage 4 Report</h3><p>Select <strong>Film Listing - Tutorial 1 Stage 4</strong> from the tutorials menu (Alternatively you can point your browser at the URL <strong>http://{SERVER_ADDRESS}/{REPORTICO_INSTALL_DIRECTORY}/run.php?project=tutorials&amp;execute_mode=PREPARE&amp;xmlin=tut1_4_films.xml</strong>). You are now ready to start the fourth stage of this tutorial.</p>
<p>Note that the starting point for this stage follows directly from stage 3 and is virtually the same report that you created in stage 3.</p><hr />
   <a name="tut1_4_simpexp"></a><h3 class="title">Create a group</h3><p>In this stage you will group the report by category</p>
<p>Before adding the category group we will change our main query select statement to order the report output by category. The grouping will only happen correctly if the the data is sorted by our group. This is because group headers will be printed whenever the group field changes.</p>
   <p>So enter report design mode and select the <strong>Query Details</strong> tab. Change the report query to</p>
   <p><pre>
SELECT film.film_id film_id, title title, cat_desc cat_desc, country.country_name country_name, year year 
FROM reptut_film film, reptut_country country, reptut_category category 
WHERE 1 = 1         AND film.cat_code = category.cat_code
AND film.country_code = country.country_code  
ORDER BY  cat_desc, title ASC
</pre></p>
   <p>Now select the <strong>Output</strong> tab followed by the <strong>Groups</strong> subtab. Click on the  <strong>Add</strong> button which will create a new Group Button. Click on this button and set the  <strong>Group on column</strong> value to cat_desc.</p>
   <p>To enter the group header values, select the <strong>Headers</strong> sub tab and click the <strong>Add</strong> button. Select the  <strong>Header 0</strong> button and set the  <strong>Group Header Column</strong> to cat_desc. This says that before each category group data, the report should print the category description.</p>
   <p>Now enter the group trailer values by selecting the  <strong>Trailers</strong> option. In this section we will indicate that we want to show the group minimum, maximum, sum and average year values below the year column on the report. To set the minimum year trailer, press the  <strong>Add</strong> button and set the <strong>Group Trailer Value Column</strong> column to minyear and the  <strong>Group Trailer Display Column</strong> column to year. This says that after each category set, the report should show the minimum year below the year column. Do the same for maxyear, sum year and avgyear setting these to display under the year column as well.</p>
   <p>Now run the report to check that your group headers and trailers are displayed. Notice however that the report detail section still shows the category description and the cumulative year minimum, maximum, sum and average values. Since these are really for the group headers and trailers we want to hide them from the report detail. So go back to design mode, select the <strong>Query Details=&gt;Query Columns</strong> sub tab and for each of the columns cat_desc, minyear, maxyear, sumyear and avgyear set the Show or Hide parameter to hide. Rerun the report to check that these columns are removed from the report body.</p><hr />
   <a name="tut1_4_cumulexp"></a><h3 class="title">Create group sums, averages, minums, maximums</h3><p>The current report will not show group minimums, maximums etc but rolling cumulative values that do not reset on each category change. To turn the existing cumulative year values to be group related, we need to modify each related assignment. So to change the minyear assignment to a group minimum, select the <strong>Assignments</strong> tab, select the minyear assignment and change the expression to include the group. That is change it to <pre class="listing">min({year},{cat_desc})</pre>. This adds cat_desc as an extra parameter to the min function. Now do the same for the maxyear, sumyear and avgyear columns.</p>
   <p>Rerun the report and check that the cumulative year values relate to the category group.</p><hr />
   <a name="tut1_2_check"></a><h3 class="title">Checking Your Report</h3><p>Run the report. This report groups the films by category. You should see group headers showing the category name. Also at the end of each category you will see the minimum, maximum year as well as the year average and total. Notice that the category and year summary values are not shown in the detail section because we have hidden them as they are now summary values only.</p><hr /></span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="../reportico/tutorial_reportico.tutorial1_3.pkg.html">Prev</a></td>
<td width="34%" align="center" valign="top"><a href=
"../reportico/tutorial_reportico.howto.pkg.html">Up</a></td>
<td width="33%" align="right" valign="top"><a href=
"../reportico/tutorial_reportico.tutorial1_5.pkg.html">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top">Tutorial 1 Stage 3 - Working with expressions using assignments</td>
<td width="34%" align="center" valign="top">Reportico Tutorial</td>
<td width="33%" align="right" valign="top">Tutorial 1 Stage 5 - Including database graphics into the report and generating drilldowns</td>
</tr>
</table>
        <div class="credit">
		    <hr />
		    Documentation generated on Mon, 09 Jun 2014 18:10:08 +0100 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>